package com.huawei.control.order;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.huawei.bean.Address;
import com.huawei.model.OrderModel;
import com.huawei.utils.EasyFactory;

/**
 * Servlet implementation class orderPreModifyControl
 */
@WebServlet("/orderPreModifyControl")
public class orderPreModifyControl extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public orderPreModifyControl() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		// 使用form表单的条件进行查询
				// 取出当前修改用户的id信息
				
//				String strAid = request.getParameter("aid");
//				System.out.println("strAid::::"+strAid);
//				// 调用Medol进行业务逻辑
//				Address addressB = EasyFactory.getNewInstance(OrderModel.class).queryAddressById(strAid);
//				
//				System.out.println(addressB);
				System.out.println("进入修改前跳转");
				Object objAddress = request.getSession().getAttribute("modifyAddressBean");
				Address address = new Address();
				address = (Address) objAddress;
				// 把查询结果集转换为json字符串格式，借助于第三方工具 Alibaba 的 fastjson工具 （进行了日期格式转换处理）
				String strJson = JSON.toJSONStringWithDateFormat(address, "yyyy-MM-dd HH:mm:ss",
						SerializerFeature.WriteDateUseDateFormat);

				// 获取response中的流操作对象PrintWriter
				PrintWriter pw = response.getWriter();
				// 写出内容到浏览器客户端
				pw.write(strJson);
				pw.flush();
	}

}
